Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stage2: add TD Partitioning support #419

Merged
merged 13 commits into from
Oct 23, 2024

Conversation

peterfang
Copy link
Contributor

This is the second half of the TDX enabling work in stage2. It enables SVSM running on a TDP platform to boot until the last jump in stage2_main(). It also adds support for serial console.

@peterfang peterfang force-pushed the dev-tdp-stage2 branch 2 times, most recently from 285a867 to a323d9f Compare July 31, 2024 05:48
@peterfang
Copy link
Contributor Author

peterfang commented Aug 5, 2024

Will update this PR again after #432 is merged since that impacts our stage1 trampoline logic

@peterfang
Copy link
Contributor Author

PR updated. TDP boots stage2 with stage2 moved to 8MB.

@joergroedel joergroedel added the wait-for-review PR needs for approval by reviewers label Aug 27, 2024
Copy link
Member

@joergroedel joergroedel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pointed out two problems which need fixing, other than that it looks good to me. With the log::info! issue fixed it boots for me on SNP and testing passes.

kernel/src/platform/mod.rs Outdated Show resolved Hide resolved
kernel/src/stage2.rs Show resolved Hide resolved
@joergroedel joergroedel added wait-for-update PR is waiting to be updated to address review comments and removed wait-for-review PR needs for approval by reviewers labels Aug 27, 2024
Since both the stage2 bootloader and the SVSM kernel dump the CPUID
page, there needs to be a page present at the respective GPA on TDP
platforms. Insert a normal zero page at the CPUID page location so that
dump_cpuid_table() can work as expected.

Signed-off-by: Peter Fang <[email protected]>
Since the SVSM kernel touches the secrets page in svsm_start(), there
needs to be a page present at the respective GPA on TDP platforms.
Insert a normal zero page at the secrets page location so that the SVSM
kernel can touch it without issues.

Signed-off-by: Peter Fang <[email protected]>
Clean up formatting and crate ordering.

Signed-off-by: Peter Fang <[email protected]>
Add the tdx-tdcall crate in preparation for the upcoming TDX enabling
changes.

Signed-off-by: Peter Fang <[email protected]>
Stage2LaunchInfo has been increased to 48 bytes. Make the according
changes in stage1 trampoline.

Signed-off-by: Peter Fang <[email protected]>
Setting the initial location counter has no effect since all of the
addresses before edata are derived based on the subsequent locations.

Signed-off-by: Peter Fang <[email protected]>
Add GHCI-based PIO driver to TdpPlatform. This implementation translates
all of the in/out operations to TDVMCALL operations as required by the
GHCI spec.

Additionally, move console initialization to env_setup() to enable it as
early as possible.

Signed-off-by: Peter Fang <[email protected]>
Make stage2 a tad more verbose by signaling when it's about ready to
jump into the SVSM kernel.

Signed-off-by: Peter Fang <[email protected]>
phys_addr_sizes should be the entirety of CPUID leaf 0x80000008.EAX, not
just the Physical Address Bits field.

Signed-off-by: Peter Fang <[email protected]>
@peterfang
Copy link
Contributor Author

Updated this PR after #463 got merged

kernel/src/types.rs Outdated Show resolved Hide resolved
This is in preparation for the upcoming changes to
PageTable::virt_to_phys(). Since 1G huge pages are architecturally
permissible when translating a virtual address, PAGE_SIZE_1G is now a
valid page size even though it's currently not actively used anywhere.

Signed-off-by: Peter Fang <[email protected]>
PageFrame is an enum describing not only a physical address, but also
the page frame to which it belongs.

- PageFrame::address(): return its internal PhysAddr
- PageFrame::start(): return the beginning of the page frame
- PageFrame::end(): return the end of the page frame

Signed-off-by: Peter Fang <[email protected]>
virt_to_frame() not only returns the translated physical address, but
also returns the size of the underlying page through PageFrame.

Signed-off-by: Peter Fang <[email protected]>
On TDP platforms, page validation means page acceptance. Implement
validate_{physical, virtual}_page_range() using the tdx-tdcall crate for
this TDCALL operation. Page invalidation simply means zeroing out the
page on TDP platforms.

Signed-off-by: Peter Fang <[email protected]>
@peterfang
Copy link
Contributor Author

Updated the PR based on feedback

Copy link
Member

@joergroedel joergroedel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me now.

@joergroedel joergroedel merged commit ef1b963 into coconut-svsm:main Oct 23, 2024
3 checks passed
@peterfang peterfang deleted the dev-tdp-stage2 branch October 24, 2024 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wait-for-update PR is waiting to be updated to address review comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants